Skip to content

Add support for GameInput API on Windows#116055

Open
Nintorch wants to merge 1 commit intogodotengine:masterfrom
Nintorch:windows-gameinput
Open

Add support for GameInput API on Windows#116055
Nintorch wants to merge 1 commit intogodotengine:masterfrom
Nintorch:windows-gameinput

Conversation

@Nintorch
Copy link
Copy Markdown
Member

@Nintorch Nintorch commented Feb 8, 2026

This PR enables GameInput API backend for SDL on Windows. I know we have already discussed this API here, but in this PR we don't include GameInput headers/code, GameInput is downloaded with a script here, so it should be okay.

This PR also removes unused backends in Godot (RawInput, WGI). DirectInput is not replaced by GameInput in this PR for devices with force feedback (racing wheels) since it's still used because of the haptics subsystem and #114642 , and XInput is used as a fallback if GameInput is not enabled in the build (if GameInput is enabled, XInput backend is not compiled). and XInput is used as a fallback for devices that aren't supported properly by current GameInput backend but are supported by XInput (arcade sticks, racing wheels, flight sticks, etc) (But I haven't tested these devices with GameInput, because I don't have them, that's why I decided to keep XInput).

With this PR the detection of my Xbox One controller has changed:

	print(Input.get_connected_joypads())
	for i in Input.get_connected_joypads():
		print(Input.get_joy_name(i), ' ', Input.get_joy_guid(i), ' ', Input.get_joy_info(i))
[0]
Xbox One S Controller 030058345e040000ea02000000006701 { "raw_name": "Xbox One S Controller", "vendor_id": "1118", "product_id": "746" }

Note that the GUID ends with 6700, which means that this API is actually used. See the line 147 of thirdparty\sdl\joystick\gdk\SDL_gameinputjoystick.c:

    elem->guid = SDL_CreateJoystickGUID(bus, vendor, product, version, manufacturer_string, product_string, 'g', 0);
image

TODO:

TODO to fix regressions:

  • Fix DirectInput mappings compatibility
  • Make the driver read inputs if the app is unfocused
  • Fallback to DirectInput for non-gamepad devices if both DirectInput joystick and DirectInput haptics backends are used
  • Check if this PR breaks Godot Windows apps under Wine or Proton
  • Check for FPS drops with Xbox controllers connected

TODO for separate PRs:

@bruvzg
Copy link
Copy Markdown
Member

bruvzg commented Feb 8, 2026

this PR we technically don't include GameInput headers/code as they are already provided on the CI machines

This won't work, since the official build system won't have them and users making custom builds won't have them.

What can be done is making this optional (with Scons argument) and add download script for the headers, like we do for DX12 stuff (see install_d3d12_sdk_windows.py).

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Feb 9, 2026

This driver broke controller mapping for my DInput controller :( I will work on fixing this issue.

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Feb 9, 2026

I have fixed the mapping issue, but I think this PR would definitely conflict with #114642 , not sure if a controller that was opened with the GameInput driver can be used with DirectInput haptic effects.
Matter of fact, controller hotplugging for DirectInput controllers in GameInput doesn't work if DirectInput is enabled. If it's disabled then everything is okay.

Maybe if we decide to use GameInput instead of DirectInput, I or someone else would have to create an SDL haptic driver for GameInput :(

And also GameInput doesn't support retrieving input from devices if the application is not in focus, unless I can do something with it.

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Feb 9, 2026

Made a PR that may or may not be better than this approach in the short term: #116101

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Feb 12, 2026

GameInput installation script is done and it makes the GCC Windows template compile!

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Feb 28, 2026

Here's something that I observed when I added several printf calls in joystick/gdk/SDL_gameinputjoystick.c: GameInput doesn't tell us the names of the connected devices (info->deviceStrings and info->displayName are NULL, doesn't matter whether it's an XInput device or not), which means currently we basically have to use DirectInput for non-gamepad controllers unless we want to only rely on controller mappings to get the controller names (which means unmapped controllers won't get a human-readable name). :(

And I'm pretty sure that XInput controllers other than the ones from Xbox don't have a human-readable name in this PR either. I don't have other XInput controllers to check that though. In this case, what name should we assign to those controllers: "XInput Controller # .." to not break compatibility or "GameInput Controller"?

EDIT: I decided to use "GameInput Gamepad", I will add a new commit here soon.

@Nintorch Nintorch force-pushed the windows-gameinput branch 3 times, most recently from a63674a to 87ca4d5 Compare February 28, 2026 16:22
@Nintorch Nintorch removed the request for review from a team March 3, 2026 17:16
@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Mar 5, 2026

Now that I think about it, is it possible to check later if this PR breaks Xbox controllers in Windows Godot apps under Wine or Proton?

@AL2009man
Copy link
Copy Markdown

AL2009man commented Mar 5, 2026

quick questions: i've heard claims GameInput seem to cause "FPS Drops" if a Xbox Controller is connected, the solution seems to be to disable GameInput Service directly. This solution seems to apply to selected games like Gears of War: Reloaded and Marathon (2026) despite actual GameInput API usage is currently unverified.

since that claim could be dubious, I think it's possible to do a benchmark test to see if it's true?

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Mar 6, 2026

As it turns out, there have been quite a few modifications to the GameInput joystick backend in SDL 3.4, so I will need to update this PR to use those changes if possible. https://github.com/libsdl-org/SDL/blob/release-3.4.x/src/joystick/gdk/SDL_gameinputjoystick.cpp

EDIT: Done! This change also allowed GameInput to properly report device names.

@Nintorch Nintorch marked this pull request as draft March 6, 2026 08:49
@Nintorch Nintorch force-pushed the windows-gameinput branch from 87ca4d5 to fc3929a Compare March 6, 2026 13:11
@Nintorch Nintorch marked this pull request as ready for review March 6, 2026 13:12
@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Mar 6, 2026

quick questions: i've heard claims GameInput seem to cause "FPS Drops" if a Xbox Controller is connected, the solution seems to be to disable GameInput Service directly. This solution seems to apply to selected games like Gears of War: Reloaded and Marathon (2026) despite actual GameInput API usage is currently unverified.

since that claim could be dubious, I think it's possible to do a benchmark test to see if it's true?

I tried to test it by disabling VSync and printing FPS, but I couldn't find any differences at the moment

@t-schreibs
Copy link
Copy Markdown

I've been trying to chase around the 5+ controller Windows issue on GitHub - is this PR the latest on that front? I want to make sure I'm notified when a potential solution emerges so I can test on my game 🙏

@Nintorch
Copy link
Copy Markdown
Member Author

Nintorch commented Mar 13, 2026

I've been trying to chase around the 5+ controller Windows issue on GitHub - is this PR the latest on that front? I want to make sure I'm notified when a potential solution emerges so I can test on my game 🙏

This PR is indeed the latest one about solving the issue of using more than 4 Xbox/XInput controllers on Windows! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for using more than 4 simultaneous controllers on Windows

5 participants